#include "Textured.h"

Textured::Textured(Image &texture,int width, int height) : Sprite() {
    this->texture = texture;
    result.Create(width, height);
        
    for (int y = 0; y <= height; y += texture.GetHeight()) {
        for (int x = 0; x <= width; x += texture.GetWidth()) {
            result.Copy(this->texture, x, y);
        }
    }
    
    SetImage(result);
    SetSubRect(Rect<int>(0, 0, width, height)); // Ensure there is no overflow
}